package com.nacos.users.controller;

import com.nacos.users.entity.User;
import com.nacos.users.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
@RefreshScope //Spring Cloud 原生注解 @RefreshScope 实现配置自动更新
public class UserController {
    @Value("${useLocalCache:false}")
    private boolean useLocalCache;

    @Autowired
    private UserService userService;


    @GetMapping("list")
    public List<User> list(){
        return userService.list();
    }

    @GetMapping("findById")
    public User findById(String id){

        return new User();
    }

    @GetMapping("find")
    public Boolean find(){

        return useLocalCache;
    }




    @PostMapping("add")
    public Object add(@RequestBody User user){

        return null;
    }

    @GetMapping("delete")
    public Object delete(String ids){

        return null;
    }
}
